package sqls

import "database/sql"
/**
	获取结果集
 */
func GetDataList (rows *sql.Rows) []map[string]interface{}{

	tableData := make([]map[string]interface{},0)
	columns, _ := rows.Columns()
	length := len(columns)
	//结果集
	values := make([]interface{}, length)
	//指针
	valuePtrs := make([]interface{}, length)

	for rows.Next() {
		for i := 0; i < length; i++ {
			valuePtrs[i] = &values[i]
		}
		rows.Scan(valuePtrs...)
		entry := make(map[string]interface{})
		for i, col := range columns {
			var v interface{}
			val := values[i]
			b, ok := val.([]byte)
			if ok {
				v = string(b)
			} else {
				v = val
			}
			entry[col] = v
		}
		tableData = append(tableData, entry)
	}
	return tableData
}